﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using pswb.Controls;
using WeifenLuo.WinFormsUI.Docking;

namespace pswb.Forms.ProcessEdit
{
    public partial class frmProcessProperty : DockContent
    {
        private object _selected;

        public object SelectedObject
        {
            get { return _selected; }
            set
            {
                _selected = value;
                setObject(value);
            }
        }
                
        public frmProcessProperty()
        {
            InitializeComponent();
        }

        private void setObject(object obj)
        {
            //controlPropertyGrid1.BrowsableAttributes = atrCol;
            controlPropertyGrid1.HiddenAttributes = ParseAttributes(new string[] { "Accessibility", "Appearance", "Behavior", "Data", "Focus", "Layout", "Docking", "Misc", "Window Style" });
            controlPropertyGrid1.SelectedObject = obj;
            textBox1.Text = obj.GetType().ToString();
        }

        private AttributeCollection ParseAttributes(string[] categorynames)
        {
            if (categorynames == null) return null;
            Attribute[] attributes = new Attribute[categorynames.Length];
            for (int iattribute = 0; iattribute < categorynames.Length; iattribute++)
            {
                attributes[iattribute] = new CategoryAttribute(categorynames[iattribute]);
            }
            return new AttributeCollection(attributes);
        }

        private void frmProcessProperty_Load(object sender, EventArgs e)
        {
            
        }
    }
}
